<%@ page
	import="merlin.beans.*,merlin.dao.*,merlin.managers.*,merlin.servlets.*,merlin.utils.*"
	contentType="text/html;charset=windows-1252"
%>

<%
	// remove any pre-existing session for this user.
	if(session.getAttribute("username") != null){
		session.invalidate();
	}
%>

<html>
	<head>
		<meta HTTP-EQUIV="Cache-Control"  CONTENT="no-cache" />
		<meta HTTP-EQUIV="Expires"        CONTENT="1 Jan 1980" />
		<meta HTTP-EQUIV="MaxAge"         CONTENT="0" />
		<meta HTTP-EQUIV="Pragma-Control" CONTENT="no-cache" />

		<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
		<title>Merlin Scott Management System</title>
		<script>
			function isBlank(str){
				var len = str.length;
				if(len==0)return true;	// zero-length string
				for(i=0;i<len;i++){
					if(str.charAt(i) !=' ' && str.charAt(i) !='\n')return false; //some character is there
				}
				return true;
			}

			function submitFormForSearch(frm){
				// sanity check
				if(isBlank(frm.txtSearch.value)){
					alert("Enter search text");
					frm.txtSearch.focus();
					return false;
				}
				return true;
	    	}

	    	function validateForm(loginForm){
	    		if(isBlank(loginForm.txtUserName.value)){
	    			alert("Username cannot be left blank");
	    			loginForm.txtUserName.focus();
	    			return false;
	    		}
	    		if(isBlank(loginForm.txtPassword.value)){
	    			alert("Password cannot be left blank");
	    			loginForm.txtPassword.focus();
	    			return false;
	    		}
				return true;
	    	}
		</script>
		<link href="css/master.css" rel="stylesheet" type="text/css">
	</head>
	<body onload="document.loginForm.txtUserName.focus()">
		<jsp:include page = "mr_header.jsp"/>
		<table width="750" border="0" cellspacing="0" cellpadding="0" align="center">
			<tr>
				<td width="180">
					<div class="sidenav">
						<div id="LCindustry">
							<h5>Industry Search</h5>
						</div>
	 					<form action="merlin" name="frmSearch" method="post" onsubmit="return submitFormForSearch(this)">
					 		<input type="hidden" name="mode" value="searchReportsByReportDesc">
					 		<input type="hidden" name="pageName" value="mr_searchReports.jsp">
					 		<input type="text" name="txtSearch" class="search"/><input type="image" src="../MSAL/new-images/search-go.jpg" alt="Search" width="30" height="20" title="Search">
			    		</form>
					</div>
					<div class="sidenav">
						<div id="LCexisting">
							<h5>Existing Customers</h5>
						</div>
						<ul>
							<li><a href="welcomeContent.jsp">Request a FREE Update to Your Report </a><a href="welcomeContent.jsp"></a></li>
						</ul>
						<div id="LCnew">
							<h5>New to the Site?</h5>
						</div>
						<ul>
							<li><a href="mr_searchReports.jsp">Order a Report</a></li>
							<li><a href="mr_searchReports.jsp">Find a Report of Interest</a></li>
							<li><a href="book.jsp">Book Contents</a></li>
							<li><a href="database.jsp">Searchable Database Contents</a></li>
							<li><a href="samplelayouts/SampleAnalysis.jsp">Our Analysis</a></li>
							<li><a href="enquiries.jsp">View a list of all available report titles</a></li>
						</ul>
  					</div>
					<p></p>
				</td>
        		<td width="20"><img src="spacer.gif" width="20" height="1"></td>
        		<td width="550">
					<div class="content-main">
						<div class="rightColumn">
							<div>
								<table width="300" cellpadding="0" cellspacing="0">
									<tr>
										<td>
											<div style="height:3.0cm;">
											</div>
											<div align='center' style="height:15px;">
											<%
												String err = (String)request.getAttribute("error.login");
												if(err != null){
													out.println("<span align='center' STYLE='FONT: 11px verdana,arial,sans-serif;color:red;font-weight:bold'>" + err + "</span>");
												}
												String msg = (String)request.getAttribute("message");
												if(msg != null){
													out.println("<span align='center' STYLE='FONT: 11px verdana,arial,sans-serif;color:GREEN;;font-weight:bold'>" + msg + "</span>");
												}
											%>
											</div>
											<br>
											<form name="loginForm" method="post" action="merlin" onsubmit =" return validateForm(this)">
												<input type="hidden" name="mode" value="loginForControlSystem">
												<input type="hidden" name="reportTitle">
												<table align="center" width="100%" border="0">
													<tr>
														<td colspan="2" align="center" style='color:white;height:23px;font: 11px verdana,arial, sans-serif ;background:url("mr_images/Long-Bar-green.jpg") no-repeat;' >
															<h4>Merlin Scott Management Logon</h4>
														</td>
													</tr>
													<tr>
														<td>&nbsp;</td>
													</tr>
													<tr>
														<td width="30%" style='font:11px verdana,arial,sans-serif;'>
															&nbsp;Username
														</td>
														<td width="70%">
															<input type="text" name="txtUserName" style="width:150px;text-transform:lowercase;font:11px verdana,arial,sans-serif;"value= '<%= request.getParameter("txtUserName")!=null ? request.getParameter("txtUserName") : "" %>' >
														</td>
													</tr>
													<tr>
														<td width="30%" style='font:11px verdana,arial,sans-serif;'>
															&nbsp;Password
														</td>
														<td width="70%" >
															<input type="password" name="txtPassword" style='font: 12px arial, verdana, sans-serif ;width:150px'>
														</td>
													</tr>
													<tr>
														<td>
														</td>
														<td colspan="1" align="right">
															<input type="SUBMIT" name="btnLogin" value="Log On" style="margin-right:20px;font: 11px verdana,arial, sans-serif ;">
														</td>
													</tr>
												</table>
											</form>
										</td>
									</tr>
								</table>
							</div>
						</div>
					</div>
				</td>
			</tr>
	</table>
	<jsp:include page="mr_footer.jsp"/>
  </body>
</html>